Implement a fuzzy diffing option for interdiff#147
Closed
kerneltoast wants to merge 3 commits intotwaugh:masterfrom
Closed
Implement a fuzzy diffing option for interdiff#147kerneltoast wants to merge 3 commits intotwaugh:masterfrom
kerneltoast wants to merge 3 commits intotwaugh:masterfrom
Conversation
It's difficult to conditionally add additional arguments to the patch execution in apply_patch() because they are placed within a compound literal array. Make the arguments more extensible by creating a local array and an index variable to place the next argument into the array. This way, it's much easier to change the number of arguments provided at runtime.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #147 +/- ##
==========================================
- Coverage 85.78% 85.74% -0.05%
==========================================
Files 15 15
Lines 8112 8264 +152
Branches 1620 1664 +44
==========================================
+ Hits 6959 7086 +127
- Misses 1153 1178 +25
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Contributor
Author
|
@twaugh codecov aside, what do you think about the fuzzy feature? Are you (un)opposed to the idea? |
This implements a --fuzzy option to make interdiff perform a fuzzy comparison between two diffs. This is very helpful, for example, for comparing a backport patch to its upstream source patch to assist a human reviewer in verifying the correctness of the backport. To achieve fuzzy diffing: Instead of creating a different dummy original file for p1 and p2 and applying p1 to p2's original file and p2 to p1's original file, use p1's original file for both cases when fuzzy diffing. This way, interdiff can rely upon the patch command to fuzz the line offset and context differences between hunks in p1 and p2. And then the final diff command at the end will show the remaining differences using the same base file, so it won't report hunks as differing just because of differing line offsets. The diff command can't do any fuzzy diffing, hence why we need to rely on the patch command for this capability. The fuzzy diffing option also handles rejected hunks by showing them in the output as a differing hunk. And it tries to avoid *additionally* showing the *reverse* of the rejected hunks by applying the rejected hunks with maximum fuzz, so that the final diff command doesn't show them.
205fb3d to
e45063a
Compare
Owner
|
I like it a lot actually, and it's definitely something people have asked for before (in fact I think it's often assumed it will just work). Does it avoid exposing 'unline's? |
Contributor
Author
|
Yes, it doesn't expose any unlines. |
Allow the user to append =N to `--fuzzy` to specify the maximum number of context lines for `patch` to fuzz.
Contributor
Author
|
Superseded by #156 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This implements a --fuzzy option to make interdiff perform a fuzzy comparison between two diffs. This is very helpful, for example, for comparing a backport patch to its upstream source patch to assist a human reviewer in verifying the correctness of the backport.